QuickTime 4 API Documentation

3D Graphics Programming with QuickDraw 3D 1.5.4

Previous | QD3D Book | Overview | Chapter Contents | Next |

General Polygons

Figure 8 shows a general polygon.

Figure 8 A general polygon

Labels

ASCII
GeneralPolygon
Binary
gpgn ( = 0x6770676E )

Polygon data data type

uns32               nVertices
Point3D             vertices[nVertices]
nVertices
The number of vertices of this contour of the general polygon.
vertices[]
An array of vertices that define this contour of the general polygon.

Data Format

Uns32                               nContours
PolygonData                         polygons[nContours]
nContours
The number of contours of the general polygon.
polygons[]
An array of contours that define the general polygon.

Data Size

sizeof(PolygonData) = 4 + nVertices * 12

sizeof(GeneralPolygon) = 4 + sizeof(polygons[0...nContours-1])

Description

A general polygon is a closed plane figure defined by one or more lists of vertices. In other words, a general polygon is a polygon defined by one or more contours . Each contour may be concave or convex, and contours may be nested. All contours, however, must be coplanar. A general polygon can have holes in it. If it does, the even-odd rule is used to determine which regions are included in the polygon. Attributes may be assigned to each vertex of each contour of a general polygon and to the entire general polygon.

Default Surface Parameterization

None.

Parent Hierarchy

Shared, shape, geometry.

Parent Objects

None.

Child Objects

Attribute set, general polygon hint, vertex attribute set list (all optional). Use an attribute set to attach attributes to an entire general polygon. Use a general polygon hint to specify whether a general polygon is concave, convex, or complex; see "General Polygon Hints" for complete details on this object. Use a vertex attribute set list to assign attributes to the vertices of the contours of a general polygon. For purposes of attribute assignment, the vertices of a general polygon are indexed in the order of their occurrence in the specification of that polygon; the index does not distinguish between contours. For purposes of attribute assignment, the n th contour of a general polygon is the contour defined by (polygons[n-1])[1] , and the index of the n th contour is n -1. The n th vertex of a general polygon is the p th vertex of the m th contour, where

m = max{k £ nContours : S0£i<k-1 (polygons[i])[0] < n},

and n = S0£i<m (polygons[i])[0]+ p; the index of the nth vertex of a general polygon is n-1. The pth vertex of the mth contour of a general polygon is the (S0£i<m-1 (polygons[ i ])[0] + p )th vertex of the general polygon; its index is S0£i<m-1 (polygons[ i ])[0] + (p - 1). See "Face Attribute Set Lists" , and "Vertex Attribute Set Lists" , for explanations of the structure and syntax of these objects.

Example

Container (
    GeneralPolygon (
        2                           # nContours
    #contour 0
        3                           # nVertices, contour 0
        -1 0 0                      # vertex 0
        1 0 0                       # vertex 1
        0 1.7 0                     # vertex 2
    #contour 1
        3                           # nVertices, contour 1
        -1 0.4 0                    # vertex 3
        1 0.4 0                     # vertex 4
        0 2.1 0                     # vertex 5
    )

    Container (
        VertexAttributeSetList ( 6 Exclude 2 0 4 )          #see note
        Container (
            AttributeSet ( )                    # vertex 1
            DiffuseColor ( 0 0 1 )
        )
        Container (
            AttributeSet ( )                    # vertex 2 (contour 0)
            DiffuseColor ( 0 1 1 )
        )
        Container (
            AttributeSet ( )                    # vertex 3 (contour 1)
            DiffuseColor ( 1 0 1 )
        )
        Container (
            AttributeSet ( )                    # vertex 5 (contour 1)
            DiffuseColor ( 1 1 0 )
        )
    )
    Container (
        AttributeSet ( )
        DiffuseColor ( 1 1 1 )
    )
)

In the above example, the general polygon has two contours. Each contour is a triangle. The triangles overlap. The intersection of the triangles is included in an even number of contours; thus, it constitutes a hole in the general polygon. The relative complements of the triangles are included in an odd number of contours; thus, they are included in the general polygon.

Default Size

None.


© 1997 Apple Computer, Inc.

Previous | QD3D Book | Overview | Chapter Contents | Next |